<template>
	<view class="content">
		<u-navbar bgColor="#fff" :placeholder="true" :fixed="true" @leftClick="$back" title="dream约文" titleStyle="{'color': '#000'}">
			
		</u-navbar>
		<image :src="'/images/qbg_02.png' | formatImgUrl" class="bei" mode=""></image>
		<view class="dingbox" :style="{'padding-bottom': paddingBottomHeight + 'rpx'}">

			<view class="neibox">
				<view class="title">
					签约入团<br>
					福利享不停！
				</view>
				<view class="lvbg" v-if="info.hasOwnProperty('id') && info.id !== undefined ">
					<image :src="'/images/zhang_01.png' | formatImgUrl" class="zhangpic" mode=""></image>
					<scroll-view scroll-y="true" class="huabox">
						<view class="huatitle">
							签约入团
						</view>
						<view class="haobox">
							<view class="haotitle">
								团号
							</view>
							<view class="huanum">
								{{number}}
							</view>
						</view>
						<view class="haobox">
							<view class="haotitle">
								团名
							</view>
							<view class="huanum">
								{{info.name}}
							</view>
						</view>
						<view class="xztxt bor">
							<view class="top_a">
								简介:
							</view>
						
							1.约稿佣金按天结算，每周三、周五、周日可提现
						</view>
						
						<view class="haobox">
							<view class="haotitle">
								群号
							</view>
							<view class="huanum">
								{{info.qq}}
							</view>
						</view>
											
											
						<view class="haobox">
							<view class="haotitle">
								时间
							</view>
							<view class="huanum">
								12个月
							</view>
						</view>
						
						
						<view class="haobox">
							<view class="haotitle">
								分成
							</view>
							<view class="huanum">
								90%
							</view>
						</view>
						
						<view class="xztxt">
							签约须知：<br>
							1.约稿佣金按天结算，每周三、周五、周日可提现。<br>
							2.申请退团以及申请转团联系团长。<br>
							3.首次签约团队，3个月内不能强制解约。<br>
							4.在签约期限内，写手不能签约其它团队，或是开小号签约其他团队。<br>
							5.签约团队后，能够提现的佣金计算公式是100（完成订单的粮币）* 0.9－团队抽取的佣金金额<br>
							6.如在团内遇到争议，且无法与团长协商解决，请保留好相关证据，进行申诉！<br>
							7.请阅读并同意<text @click.stop="goToOtherxie(9)">《团队签约协议》</text>。
						</view>
						
					</scroll-view>

				</view>


			</view>
			<view class="dibox">
				<view class="zaibox">
					<view class="zaileft">
						<view class="dbox">
							<view class="zaititle">
								签约入团
							</view>
							<view class="text">
								团内资源扶持速度成长
							</view>
						</view>
						<view class="zaitxt">
							我已确认全部内容
						</view>
					</view>
					<view class="que" @click="postApply">
						确认申请
					</view>
				</view>
				<view class="xiebox" @click="isRead =( isRead == 2?0:2)" :class="isRead == 1 ? 'shake-horizontal' : ''">
					<label>
						<!-- <checkbox style="transform: scale(0.7);" :checked="isRead" /> -->
						<u-checkbox shape="circle" size="14" :checked="isRead" activeColor="#45C4B0" inactiveColor="#999" @change="changeBox"></u-checkbox>
					</label>
					<view class="xietxt">
						请阅读并同意：<text @click.stop="goToxie2">《写手入团签约协议》</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				paddingBottomHeight: 0, //苹果X以上手机底部适配高度
				number: '',
				info: {},
				isRead: false
			}
		},
		onLoad(e) {
			if (e.number) {
				this.number = e.number
				this.getInfo()
			} else {
				this.$common.errorToShow('参数异常')
			}
		},
		created() {
			let that = this;
			uni.getSystemInfo({
				success: function(res) {
					let model = ['X', 'XR', 'XS', '11', '12', '13', '14', '15'];
					model.forEach(item => {
						//适配iphoneX以上的底部，给tabbar一定高度的padding-bottom
						if (res.model.indexOf(item) != -1 && res.model.indexOf('iPhone') != -1) {
							that.paddingBottomHeight = 40;
						}
					})
				}
			});
			var url = getCurrentPages()
			this.urlPath = '/' + url[0].route

		},
		methods: {
			changeBox(e){
				this.isRead = e ? 2 : 0
			},
			goToxie2() {
				// uni.navigateTo({
				// 	url: '/pages/webview/webview?url=' + this.$config.default.Url + '/agreement/1000007'
				// })
				uni.navigateTo({
					url: '/pages/user/abount_dea?id=9' 
				})
			},
			
			getInfo() {
				this.$api.default.request('user/searchTeam', {
					num: this.number
				}, 'POST', false).then((res) => {
					if (res.code) {
						this.info = res.data
					}
				})
			},
			postApply() {
				if(this.isRead == 2){
					this.$api.default.request('user/applyTeam', {
						id: this.info.id
					}, 'POST', false).then((res) => {
						if (res.code) {
							this.$common.successToShow(res.msg, () => {
								uni.reLaunch({
									url: '/pages/user/success?id=' + res.data.id
								})
							})
						}
					})
				}else{
					this.isReadTip()
				}
			},
			isReadTip() {
				if (!this.isRead) {
					this.$common.errorToShow('请先同意用户协议');
					this.isRead = 1
					setTimeout(() => {
						this.isRead = 0;
					}, 300)
					return
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: rgba(242, 245, 242, 1);
	}

	.content {
		position: relative;
		padding: 102rpx 0;

		.bei {
			width: 100%;
			height: 100vh;
			position: fixed;
			left: 0;
			top: 0;
			z-index: -1;
		}

		.dingbox {
			position: fixed;
			left: 0;
			bottom: 0;
			width: 100%;

			.neibox {
				padding: 0 75rpx;

				.title {
					font-size: 72rpx;
					font-weight: bold;
					letter-spacing: 0px;
					line-height: 104rpx;
					padding-bottom: 48rpx;
					color: #45C4B0;
				}

				.lvbg {
					border-top-left-radius: 30px;
					border-top-right-radius: 30px;
					height: 788rpx;
					padding-top: 28rpx;
					background: #45C4B0;
					box-shadow: 0px 4px 10px 0px #45C4B0, inset 0px 4px 10px 0px rgba(255, 255, 255, 0.3);
					position: relative;

					.zhangpic {
						width: 360rpx;
						height: 346rpx;
						position: absolute;
						bottom: 0;
						right: 0;
						z-index: 1;
					}

					.huabox {
						position: relative;
						z-index: 22;
						padding: 0 48rpx;
						width: 520rpx;
						height: 816rpx;

						.huatitle {
							padding-bottom: 6rpx;
							font-size: 36rpx;
							font-weight: bold;
							line-height: 40rpx;
							letter-spacing: 0px;
							color: #FFFFFF;
						}

						.haobox {
							display: flex;
							align-items: center;
							justify-content: space-between;
							padding: 20rpx 0;
							border-bottom: 1px solid rgba(255, 255, 255, 0.1);

							.haotitle {
								font-size: 28rpx;
								font-weight: bold;
								line-height: 40rpx;
								letter-spacing: 0px;
								color: #FFFFFF;
							}

							.huanum {
								color: #FFFFFF;
								font-size: 28rpx;
								line-height: 40rpx;
							}
						}

						.xztxt {
							padding-top: 20rpx;
							font-size: 20rpx;
							letter-spacing: 0em;
							color: #FFFFFF;
							line-height: 28rpx;
							// border-bottom: 1px solid rgba(255, 255, 255, 0.1);
						}
						
						.bor{
							font-size: 28rpx;
							padding: 20rpx  0;
							border-bottom: 1px solid rgba(255, 255, 255, 0.1);
							
						}
						.top_a{
							font-weight: 700;
							font-size: 30rpx;
							width: 100%;
							height: 44rpx;
						}
					}
				}
			}

			.dibox {
				z-index: 222;
				position: relative;
				background-color: #ffffff;
				padding: 20rpx 66rpx 20rpx 54rpx;

				.zaibox {
					width: 630rpx;
					height: 80rpx;
					border-radius: 12px;
					background: #3D3D3D;
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin: 0 auto 10rpx;

					.zaileft {
						padding: 0 20rpx;

						.dbox {
							display: flex;
							align-items: center;

							.zaititle {

								font-size: 28rpx;
								font-weight: bold;
								background: linear-gradient(293deg, #45C4B0 -5%, #56E8B5 128%);
								-webkit-background-clip: text;
								-webkit-text-fill-color: transparent;
								background-clip: text;
								text-fill-color: transparent;

							}

							.text {
								font-size: 28rpx;
								font-weight: bold;
								color: #FFFFFF;
								padding-left: 8rpx;
							}
						}

						.zaitxt {
							font-size: 20rpx;
							font-weight: normal;
							letter-spacing: 0px;
							color: #999999;
						}
					}

					.que {
						width: 190rpx;
						height: 80rpx;
						border-radius: 10px;
						opacity: 1;
						background: #45C4B0;
						font-size: 24rpx;
						font-weight: bold;
						color: #FFFFFF;
						text-align: center;
						line-height: 80rpx;
					}
				}

				.xiebox {
					display: flex;
					align-items: center;
					justify-content: center;
					padding-bottom: 10rpx;

					.xietxt {
						font-size: 20rpx;
						font-weight: bold;
						color: #999999;

						text {
							font-size: 20rpx;
							font-weight: bold;
							color: #45C4B0;
							padding: 0 10rpx;
						}
					}
				}
			}
		}

	}
</style>